import service from "@/utils/request";
const DEPT_BASE_URL = "/api/";
import { RoleModel,AddUserModel,AddRoleModel } from './model'

//权限管理
class PermissionAPI{
  /**
   * 获取角色信息
   */
  static getRole(data: RoleModel) {
    return service<any, RoleModel>({
      url: `${DEPT_BASE_URL}Role/GetRoles`,
      method: 'post',
      data:data
    })
  }
  /**
   * 获取权限列表
   */
  static getPermissionList(pid:number) {
    return service<any>({
      url: `${DEPT_BASE_URL}Permission/GetMenuList`,
      method: 'get',
      params: {
        pid:pid
      }
    })
  }
  /**
   * 新增人员信息
   */
  static AddUserInfo(data: AddUserModel) {
    return service<any>({
      url: `${DEPT_BASE_URL}User/AddUser`,
      method: 'post',
      data:data
    })
  }
  /**
   * 获取角色下拉框
   */
  static getRoleSelect() {
    return service<any>({
      url: `${DEPT_BASE_URL}Role/GetRolesSelect`,
      method: 'get',
    })
  }
  //新增角色
  static addRole(data: AddRoleModel) {
    return service<any>({
      url: `${DEPT_BASE_URL}Role/AddRole`,
      method: 'post',
      data:data
    })
  }
  //删除角色
  static deleteRole(data:number) {
    return service({
      url: `/api/Role/DeleteRole`,
      method: 'post',
      data
    })
  }
  //查看角色的权限
  static getRolePermission(roleId:number) {
    return service({
      url: '/api/Permission/GetRolesPermission',
      method: 'get',
      params: {
        RoleId :roleId
      }
    })
  }
  //修改角色权限
  static updRPermission(data: any) {
    return service({
      url: '/api/Permission/SavePermission',
      method: 'post',
      data
    })
  }
}

export default PermissionAPI;